#include "message.hpp"
#include "net.hpp"

void onMessage(const yfrpc::BaseConnection::ptr& conn, yfrpc::BaseMessage::ptr& msg)
{
    std::string body = msg->serialize();
    std::cout << body << std::endl;
    auto rpc_req = yfrpc::MessageFactory::create<yfrpc::RpcRequest>();
    rpc_req->setId("11111");
    rpc_req->setMType(yfrpc::MType::RSP_RPC);
    conn->send(rpc_req);
}


int main()
{
    auto server = yfrpc::ServerFactory::create(9090);
    server->setMessageCallback(onMessage);
    server->start();
    return 0;
}